import { createRouter, createWebHistory } from 'vue-router';
import HomePage from '../views/HomePage.vue';

// DL模块路由
import DLWZsubmitOrder from '../views/DL/WZsubmitOrder/index.vue';
import DLYXLMsubmitOrder from '../views/DL/YXLMsubmitOrder/index.vue';
import DLWWQYsubmitOrder from '../views/DL/WWQYsubmitOrder/index.vue';
import DLSJZsubmitOrder from '../views/DL/SJZsubmitOrder/index.vue';

// PL模块路由
import PLWZsubmitOrder from '../views/PL/WZsubmitOrder/index.vue';
import PLYXLMsubmitOrder from '../views/PL/YXLMsubmitOrder/index.vue';
import PLWWQYsubmitOrder from '../views/PL/WWQYsubmitOrder/index.vue';
import PLSJZsubmitOrder from '../views/PL/SJZsubmitOrder/index.vue';

// 定义所有路由
const routes = [
    {
        path: '/',
        name: 'home',
        component: HomePage
    },
    // DL模块路由
    {
        path: '/DL/WZsubmitOrder',
        name: 'DLWZsubmitOrder',
        component: DLWZsubmitOrder
    },
    {
        path: '/DL/YXLMsubmitOrder',
        name: 'DLYXLMsubmitOrder',
        component: DLYXLMsubmitOrder
    },
    {
        path: '/DL/WWQYsubmitOrder',
        name: 'DLWWQYsubmitOrder',
        component: DLWWQYsubmitOrder
    },
    {
        path: '/DL/SJZsubmitOrder',
        name: 'DLSJZsubmitOrder',
        component: DLSJZsubmitOrder
    },
    // PL模块路由
    {
        path: '/PL/WZsubmitOrder',
        name: 'PLWZsubmitOrder',
        component: PLWZsubmitOrder
    },
    {
        path: '/PL/YXLMsubmitOrder',
        name: 'PLYXLMsubmitOrder',
        component: PLYXLMsubmitOrder
    },
    {
        path: '/PL/WWQYsubmitOrder',
        name: 'PLWWQYsubmitOrder',
        component: PLWWQYsubmitOrder
    },
    {
        path: '/PL/SJZsubmitOrder',
        name: 'PLSJZsubmitOrder',
        component: PLSJZsubmitOrder
    },
    // 重定向路由，解决可能的404问题
    {
        path: '/:pathMatch(.*)*',
        redirect: '/'
    }
];

// 使用环境变量或默认值作为基础路径，确保开发环境和生产环境路径一致
const BASE_PATH = import.meta.env.VITE_BASE_PATH || '/';

const router = createRouter({
    history: createWebHistory(BASE_PATH),
    routes
});

export default router;